(function () {
    var account = document.getElementById('account');
    var password = document.getElementById('password');
    var login = document.getElementById('login');
    // TODO AES加密
    login.addEventListener('click', function () {
        Api.ajax({
            method: 'POST',
            url: '/login',
            data: {
                account: account.value,
                password: password.value
            },
            success: function (response) {
                console.log(response);
                if (response.code == 0) {
                    //TODO 跳转
                    var user = response.data;
                    CommonUtil.setCookie('userInfo', JSON.stringify(user));
                    //TODO 首页跳转
                    // window.location.href= 'login.html';
                } else {
                    mdui.alert('登录失败', null, null, '重新登录');
                }
            }
        })
    })
})();